import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:flutter_easyloading/flutter_easyloading.dart';
import 'package:smartloan_mdc/res/theme.dart';

abstract class BasePage extends StatefulWidget {
  const BasePage({super.key});

  @override
  State<StatefulWidget> createState() => getState();

  BasePageState getState();
}

abstract class BasePageState<T extends BasePage> extends State<T> {

  String pageName = "";
  bool appBarVisible = false;
  Color pageBgColor = AppTheme.pageBgColor;

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      backgroundColor: pageBgColor,
      resizeToAvoidBottomInset: false,
      // appBar: appBarVisible ? null : getAppBar(),
      body: WillPopScope(
        onWillPop: onWillPop,
        child: buildWidget()
      ),
    );
  }

  Widget buildWidget();

  // AppBar getAppBar() {
  //   return AppBar(
  //     // title: Text('page title'),
  //     centerTitle: true,
  //   );
  // }
  //
  // setAppBarVisible(bool visible) {
  //   setState(() {
  //     appBarVisible = visible;
  //   });
  // }

  setBgColor(Color bgColor) {
    setState(() {
      pageBgColor = bgColor;
    });
  }

  Future<bool> onWillPop() async {
    return true;
  }
}